package com.example.demo.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Component
@Slf4j
@Aspect
public class MyAspectDemo {//若语法错误不会报错，也不会生效
    @Pointcut("execution (* com.example.demo.controller.*.*(..))")
    public void pt(){};
    @Before("pt()")
    public void doBefore(JoinPoint joinPoint) {  //JoinPoint joinPoint是连接点，可以利用它来获取连接点信息
        log.info(joinPoint.getSignature().toShortString());
        log.info("执行before方法");
    }

    @After("pt()")
    public void doAfter() {
        log.info("执行after方法");
    }


}
